<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="刘清政">
  <meta name="keyword" content="hexo-theme">
  
    <link rel="shortcut icon" href="/css/images/logo.png">
  
  <title>
    
      linux/入门到精通/12-Linux压缩打包 | Justin-刘清政的博客
    
  </title>
  <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/tomorrow.min.css" rel="stylesheet">
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/css/plugins/gitment.css">

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
  
    
<script src="/js/qrious.js"></script>

  
  
    
<script src="/js/gitment.js"></script>

  
  

  
<meta name="generator" content="Hexo 4.2.0"></head>
<div class="wechat-share">
  <img src="/css/images/logo.png" />
</div>

  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>Justin-刘清政的博客</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">主页</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags/" class="item-link">标签</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives/" class="item-link">归档</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about/" class="item-link">关于我</a>
          
        </li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">主页</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags/" class="menu-link">标签</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives/" class="menu-link">归档</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about/" class="menu-link">关于我</a>
            
          </li>
        
      </ul>
    </div>
  </div>
</header>

    <div id="article-banner">
  <h2>linux/入门到精通/12-Linux压缩打包</h2>



  <p class="post-date">2020-07-06</p>
    <!-- 不蒜子统计 -->
    <span id="busuanzi_container_page_pv" style='display:none' class="">
        <i class="icon-smile icon"></i> 阅读数：<span id="busuanzi_value_page_pv"></span>次
    </span>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><h2 id="1-文件打包与压缩"><a href="#1-文件打包与压缩" class="headerlink" title="1.文件打包与压缩"></a>1.文件打包与压缩</h2><h3 id="1-什么是文件压缩"><a href="#1-什么是文件压缩" class="headerlink" title="1.什么是文件压缩?"></a>1.什么是文件压缩?</h3><p>将多个文件或目录合并成为一个特殊的文件。比如: 搬家…脑补画面 img.</p>
<h3 id="2-为什么要对文件进行压缩？"><a href="#2-为什么要对文件进行压缩？" class="headerlink" title="2.为什么要对文件进行压缩？"></a>2.为什么要对文件进行压缩？</h3><p>当我们在传输大量的文件时，通常都会选择将该文件进行压缩，然后在进行传输。<br>首先：压缩后的文件会比压缩前的文件小。一个28G的文件夹压缩后能达到6G<br>其次：多个文件传输很慢，但单个文件传输会很快，同时还能节省网络的消耗。<br>（比如: 搬家时，单行李往外拿和打包后往外拿？？你懂我意思?）</p>
<h3 id="2-Windows的压缩包与Linux的压缩包能否互通？"><a href="#2-Windows的压缩包与Linux的压缩包能否互通？" class="headerlink" title="2.Windows的压缩包与Linux的压缩包能否互通？"></a>2.Windows的压缩包与Linux的压缩包能否互通？</h3><p>在windows系统下，我们接触最多的压缩格式是 rar 或 zip ，但在Linux上使用最多的压缩格式是 zip 和 tar.gz 。当然不用担心，Linux上的压缩格式放在windows系统下都是可以正常打开的。<br>PS: Linux不支持 Windows下的 RAR 格式的压缩文件。Windows和Linux互通通常选择 zip</p>
<h3 id="3-Linux下压缩包有哪些常见的类型"><a href="#3-Linux下压缩包有哪些常见的类型" class="headerlink" title="3.Linux下压缩包有哪些常见的类型"></a>3.Linux下压缩包有哪些常见的类型</h3><table>
<thead>
<tr>
<th align="left">格式</th>
<th align="left">压缩工具</th>
</tr>
</thead>
<tbody><tr>
<td align="left">.zip</td>
<td align="left">zip压缩工具</td>
</tr>
<tr>
<td align="left">.gz</td>
<td align="left">gzip压缩工具，只能压缩文件，会删除原文件(通常配合tar使用)</td>
</tr>
<tr>
<td align="left">.bz2</td>
<td align="left">bzip2压缩工具，只能压缩文件，会删除原文件(通常配合tar使用)</td>
</tr>
<tr>
<td align="left">.tar.gz</td>
<td align="left">先使用tar命令归档打包，然后使用gzip压缩</td>
</tr>
<tr>
<td align="left">.tar.bz2</td>
<td align="left">先使用tar命令归档打包，然后使用bzip压缩</td>
</tr>
</tbody></table>
<h2 id="2-gzip打包与压缩"><a href="#2-gzip打包与压缩" class="headerlink" title="2.gzip打包与压缩"></a>2.gzip打包与压缩</h2><p>使用gzip方式进行压缩文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 仅对文件有效，对文件夹无效，压缩有文件删除，解压后压缩包删除</span></span><br><span class="line">[root@lqz ~]<span class="comment"># yum install gzip -y</span></span><br><span class="line">[root@lqz ~]<span class="comment"># gzip file      #对文件进行压缩</span></span><br><span class="line">[root@lqz ~]<span class="comment"># zcat file.gz    #查看gz压缩后的文件</span></span><br><span class="line">[root@lqz ~]<span class="comment"># gzip -d file.gz #解压gzip的压缩包</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#使用场景:当需要让某个文件不生效时,快速关闭和启用配置文件</span></span><br><span class="line">[root@lqz ~]<span class="comment"># cd /etc/yum.repos.d/</span></span><br><span class="line">[root@lqz ~]<span class="comment"># gzip *</span></span><br><span class="line">[root@lqz ~]<span class="comment"># gzip CentOS-Vault.repo --&gt; CentOS-Vault.repo.gz</span></span><br><span class="line">[root@lqz ~]<span class="comment"># zcat CentOS-Vault.repo.gz   --&gt; 查看不想解压的压缩包文件内容</span></span><br></pre></td></tr></table></figure>

<h2 id="3-zip打包与压缩"><a href="#3-zip打包与压缩" class="headerlink" title="3.zip打包与压缩"></a>3.zip打包与压缩</h2><p>使用zip命令可以对文件进行压缩打包，解压则需要使用unzip命令</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 默认情况下没有zip和unzip工具，需要进行安装</span></span><br><span class="line">[root@lqz ~]<span class="comment"># yum install zip unzip -y</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#1.压缩文件为zip包</span></span><br><span class="line"><span class="comment"># zip 压缩表名 压缩的文件</span></span><br><span class="line">[root@lqz ~]<span class="comment"># zip  filename.zip  filename </span></span><br><span class="line"><span class="comment"># 打包不通目录下的不通文件</span></span><br><span class="line">[root@lqz ~]<span class="comment"># zip  filename1.zip  file1 file2 /etc/hosts </span></span><br><span class="line"></span><br><span class="line"><span class="comment">#2.压缩目录为zip包 (不加r，只会打包一个文件夹)</span></span><br><span class="line">[root@lqz ~]<span class="comment"># zip -r  dir.zip dir/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#3.查看zip压缩包是否是完整的         </span></span><br><span class="line">[root@lqz ~]<span class="comment"># zip -T  filename.zip</span></span><br><span class="line"><span class="built_in">test</span> of filename.zip OK</span><br><span class="line"></span><br><span class="line"><span class="comment">#4.不解压压缩查看压缩包中的内容</span></span><br><span class="line">[root@lqz ~]<span class="comment"># unzip -l  filename.zip</span></span><br><span class="line">[root@lqz ~]<span class="comment"># unzip -t  filename.zip</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#5.解压zip文件包, 默认解压至当前目录          </span></span><br><span class="line">[root@lqz ~]<span class="comment"># unzip  filename.zip</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#6.解压zip内容至/opt目录</span></span><br><span class="line">[root@lqz ~]<span class="comment"># unzip filename.zip  -d /opt/</span></span><br></pre></td></tr></table></figure>

<h2 id="4-tar打包与压缩"><a href="#4-tar打包与压缩" class="headerlink" title="4.tar打包与压缩"></a>4.tar打包与压缩</h2><p>tar是linux下最常用的压缩与解压缩, 支持文件和目录的压缩归档</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#语法：tar [-zjxcvfpP] filename </span></span><br><span class="line">c   <span class="comment">#创建新的归档文件</span></span><br><span class="line">x   <span class="comment">#对归档文件解包</span></span><br><span class="line">t   <span class="comment">#列出归档文件里的文件列表</span></span><br><span class="line">v   <span class="comment">#输出命令的归档或解包的过程</span></span><br><span class="line">f   <span class="comment">#指定包文件名，多参数f写最后</span></span><br><span class="line"></span><br><span class="line">z   <span class="comment">#使用gzip压缩归档后的文件(.tar.gz)</span></span><br><span class="line">j   <span class="comment">#使用bzip2压缩归档后的文件(.tar.bz2)</span></span><br><span class="line">J   <span class="comment">#使用xz压缩归档后的文件(tar.xz)</span></span><br><span class="line">C   <span class="comment">#指定解压目录位置</span></span><br><span class="line">X   <span class="comment">#排除多个文件(写入需要排除的文件名称)</span></span><br><span class="line">h   <span class="comment">#打包软链接</span></span><br><span class="line">--hard-dereference  <span class="comment">#打包硬链接</span></span><br><span class="line">--exclude   <span class="comment">#在打包的时候写入需要排除文件或目录</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#常用打包与压缩组合</span></span><br><span class="line">czf     <span class="comment">#打包tar.gz格式 常用</span></span><br><span class="line">cjf     <span class="comment">#打包tar.bz格式 不怎么用</span></span><br><span class="line">cJf     <span class="comment">#打包tar.xz格式 不考虑</span></span><br><span class="line"></span><br><span class="line">zxf     <span class="comment">#解压tar.gz格式</span></span><br><span class="line">jxf     <span class="comment">#解压tar.bz格式</span></span><br><span class="line">xf      <span class="comment">#自动选择解压模式</span></span><br><span class="line">xvf     <span class="comment">#显示解压过程</span></span><br><span class="line">tf      <span class="comment">#查看压缩包内容</span></span><br></pre></td></tr></table></figure>

<p>1.将文件或目录进行打包压缩</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#1.以gzip归档方式打包并压缩</span></span><br><span class="line">tar czf  test.tar.gz  <span class="built_in">test</span>/ test2/</span><br><span class="line"></span><br><span class="line"><span class="comment">#2.以bz2方式压缩 </span></span><br><span class="line">tar cjf  test.tar.bz2 dir.txt dir/</span><br><span class="line"></span><br><span class="line"><span class="comment">#3.打包链接文件,打包链接文件的真实文件</span></span><br><span class="line">[root@lqz ~]<span class="comment"># cd /</span></span><br><span class="line">[root@lqz /]<span class="comment"># tar czfh local.tar.gz  etc/rc.local</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#4.打包/tmp下所有文件</span></span><br><span class="line">[root@lqz ~]<span class="comment"># cd /</span></span><br><span class="line">[root@lqz /]<span class="comment"># find tmp/ -type f | xargs tar czf tmp.tar.gz</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#5.打包/tmp下所有文件</span></span><br><span class="line">[root@lqz /]<span class="comment"># tar czf tmp.tar.gz $(find /tmp/ -type f)</span></span><br></pre></td></tr></table></figure>

<p>2.排除文件, 并打包压缩</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#1.排除单个文件</span></span><br><span class="line">[root@lqz /]<span class="comment">#  tar czf etc.tar.gz --exclude=etc/services etc/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#2.排除多个文件</span></span><br><span class="line">[root@lqz /]<span class="comment"># tar czf etc.tar.gz --exclude=etc/services --exclude=etc/rc.local etc/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#3.将需要排除的文件写入文件中</span></span><br><span class="line">[root@lqz /]<span class="comment"># cat paichu.list</span></span><br><span class="line">etc/services</span><br><span class="line">etc/rc.local</span><br><span class="line">etc/rc.d/rc.local</span><br><span class="line"><span class="comment">#指定需要排除的文件列表, 最后进行打包压缩</span></span><br><span class="line">[root@lqz /]<span class="comment"># tar czfX etc.tar.gz paichu.list etc/</span></span><br></pre></td></tr></table></figure>

<p>3.查看压缩文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#查看压缩包内容和解压</span></span><br><span class="line">[root@lqz /]<span class="comment"># tar tf  test.tar.gz</span></span><br></pre></td></tr></table></figure>

<p>4.解压缩文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#1.解压至当前目录</span></span><br><span class="line">[root@lqz /]<span class="comment"># tar xf  test.tar.gz      </span></span><br><span class="line"></span><br><span class="line"><span class="comment">#2.将解压内容存储至指定的/tmp目录</span></span><br><span class="line">[root@student ~]<span class="comment"># tar xf /etc/local.tar.gz  -C /tmp</span></span><br></pre></td></tr></table></figure>

<p>tar命令练习</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#1.环境准备</span></span><br><span class="line">[root@lqz ~]<span class="comment"># yum install mariadb-server</span></span><br><span class="line">[root@lqz ~]<span class="comment"># systemctl start mariadb</span></span><br><span class="line">[root@lqz ~]<span class="comment"># mkdir /backup</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#案例1.mysql备份及恢复</span></span><br><span class="line">[root@lqz ~]<span class="comment"># tar cJf /backup/mysql.tar.xz /var/lib/mysql</span></span><br><span class="line">[root@lqz ~]<span class="comment"># tar xf /backup/mysql.tar.xz -C /</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#案例2 mysql备份及恢复</span></span><br><span class="line">[root@lqz ~]<span class="comment"># cd /var/lib/mysql</span></span><br><span class="line">[root@lqz mysql]<span class="comment"># tar cJf /backup/mysql.tar.xz </span></span><br><span class="line">[root@lqz mysql]<span class="comment"># tar tf /backup/mysql.tar.xz</span></span><br><span class="line">[root@lqz mysql]<span class="comment"># tar xf /backup/mysql.tar.xz -C /var/lib/mysql</span></span><br></pre></td></tr></table></figure></section>
    <!-- Tags START -->
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/linux/%E5%85%A5%E9%97%A8%E5%88%B0%E7%B2%BE%E9%80%9A/11-Linux%E6%96%87%E4%BB%B6%E6%9F%A5%E6%89%BE/">
        <span class="nav-arrow">← </span>
        
          linux/入门到精通/11-Linux文件查找
        
      </a>
    
    
      <a class="nav-right" href="/linux/%E5%85%A5%E9%97%A8%E5%88%B0%E7%B2%BE%E9%80%9A/13-Linux%E8%BD%AF%E4%BB%B6%E7%AE%A1%E7%90%86/">
        
          linux/入门到精通/13-Linux软件管理
        
        <span class="nav-arrow"> →</span>
      </a>
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
      <div class="money-like">
        <div class="reward-btn">
          赏
          <span class="money-code">
            <span class="alipay-code">
              <div class="code-image"></div>
              <b>使用支付宝打赏</b>
            </span>
            <span class="wechat-code">
              <div class="code-image"></div>
              <b>使用微信打赏</b>
            </span>
          </span>
        </div>
        <p class="notice">点击上方按钮,请我喝杯咖啡！</p>
      </div>
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
      <div class="qrcode">
        <canvas id="share-qrcode"></canvas>
        <p class="notice">扫描二维码，分享此文章</p>
      </div>
    
    <!-- 二维码 END -->
    
      <!-- Gitment START -->
      <div id="comments"></div>
      <!-- Gitment END -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
    <aside class="catalog-container">
  <div class="toc-main">
  <!-- 不蒜子统计 -->
    <strong class="toc-title">目录</strong>
    
      <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#1-文件打包与压缩"><span class="toc-nav-text">1.文件打包与压缩</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#1-什么是文件压缩"><span class="toc-nav-text">1.什么是文件压缩?</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-为什么要对文件进行压缩？"><span class="toc-nav-text">2.为什么要对文件进行压缩？</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-Windows的压缩包与Linux的压缩包能否互通？"><span class="toc-nav-text">2.Windows的压缩包与Linux的压缩包能否互通？</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#3-Linux下压缩包有哪些常见的类型"><span class="toc-nav-text">3.Linux下压缩包有哪些常见的类型</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#2-gzip打包与压缩"><span class="toc-nav-text">2.gzip打包与压缩</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#3-zip打包与压缩"><span class="toc-nav-text">3.zip打包与压缩</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#4-tar打包与压缩"><span class="toc-nav-text">4.tar打包与压缩</span></a></li></ol>
    
  </div>
</aside>
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'http://www.liuqingzheng.top/linux/入门到精通/12-Linux压缩打包/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

    // error image
    $(".markdown-content img").on('error', function() {
      $(this).attr('src', 'http://file.muyutech.com/error-img.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function() {
      var src = $(this).attr('src')
      if (src !== 'http://file.muyutech.com/error-img.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()

        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="'+ src +'" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function() {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })
  })();
</script>


  <script>
    var qr = new QRious({
      element: document.getElementById('share-qrcode'),
      value: document.location.href
    });
  </script>



  <script>
    var gitmentConfig = "liuqingzheng";
    if (gitmentConfig !== 'undefined') {
      var gitment = new Gitment({
        id: "linux/入门到精通/12-Linux压缩打包",
        owner: "liuqingzheng",
        repo: "FuckBlog",
        oauth: {
          client_id: "32a4076431cf39d0ecea",
          client_secret: "94484bd79b3346a949acb2fda3c8a76ce16990c6"
        },
        theme: {
          render(state, instance) {
            const container = document.createElement('div')
            container.lang = "en-US"
            container.className = 'gitment-container gitment-root-container'
            container.appendChild(instance.renderHeader(state, instance))
            container.appendChild(instance.renderEditor(state, instance))
            container.appendChild(instance.renderComments(state, instance))
            container.appendChild(instance.renderFooter(state, instance))
            return container;
          }
        }
      })
      gitment.render(document.getElementById('comments'))
    }
  </script>




    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
<!-- 不蒜子统计 -->
<span id="busuanzi_container_site_pv">
     本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<span class="post-meta-divider">|</span>
<span id="busuanzi_container_site_uv" style='display:none'>
     本站访客数<span id="busuanzi_value_site_uv"></span>人
</span>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



  <p class="copyright">
    &copy; 2021 | Proudly powered by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank">小猿取经</a>
    <br>
    Theme by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank" rel="noopener">小猿取经</a>
  </p>
</footer>

<script>
  function async(u, c) {
    var d = document, t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async("//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js", function(){
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async("//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js", function(){
    $('figure pre').each(function(i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>





<!-- Baidu Tongji -->

<script>
    var _baId = 'c5fd96eee1193585be191f318c3fa725';
    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>


<script src="/js/script.js"></script>


<script src="/js/search.js"></script>


<script src="/js/load.js"></script>



  <span class="local-search local-search-google local-search-plugin" style="right: 50px;top: 70px;;position:absolute;z-index:2;">
      <input type="search" placeholder="站内搜索" id="local-search-input" class="local-search-input-cls" style="">
      <div id="local-search-result" class="local-search-result-cls"></div>
  </span>


  </body>
</html>